<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import="com.google.appengine.api.users.User"%>
<%@ page import="com.google.appengine.api.users.UserService"%>
<%@ page import="com.google.appengine.api.users.UserServiceFactory"%>
<%@ page import="org.teammach.laddercomp.dao.LadderManager"%>
<%@ page import="org.teammach.laddercomp.dao.BlogManager"%>

<%@ page import="org.teammach.laddercomp.shared.Ladder"%>
<%@ page import="org.teammach.laddercomp.shared.OfficialLadder"%>
<%@ page import="org.teammach.laddercomp.shared.Team"%>
<%@ page import="org.teammach.laddercomp.shared.BlogEntry"%>

<%@ page import="com.google.appengine.api.datastore.Entity"%>
<%@ page import="java.text.SimpleDateFormat"%>


<%@ page import="java.util.List"%>
<%@ page import="java.util.TimeZone"%>


<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css">
<script type="text/javascript">

 var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-23998388-1']);
 _gaq.push(['_trackPageview']);

 (function() {
   var ga = document.createElement('script'); ga.type =
'text/javascript'; ga.async = true;
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
'http://www') + '.google-analytics.com/ga.js';
   var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
 })();

</script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {

        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Round');
		<%LadderManager manager = LadderManager.INSTANCE;
			List<Ladder> ladders = manager.listLadders();
			for (int i = 0; i < ladders.size(); i++) {
				if (ladders.get(i).getUser().startsWith("Official")) {
					continue;
				}%>
    	data.addColumn('number', '<%=ladders.get(i).getUser()%>');
	
	
		<%}%>
			data.addRows(<%=ladders.get(0).getPrevRounds().size()%>);
			<%
			for(int i=0; i<ladders.get(0).getPrevRounds().size(); i++) { %>
				data.setValue(<%=i%>, 0, '<%="" + (i+1)%>');
			<%
				int k=0;
				for(int j=0; j<ladders.size(); j++) {
					if (ladders.get(j).getUser().startsWith("Official")) {
						continue;
					}
					k++;
					if(ladders.get(j).getPrevRounds().get(i) != 101) {
					%>
					data.setValue(<%=i%>, <%=k%>, <%=ladders.get(j).getPrevRounds().get(i) %>);
					<%
					}
				}
			}
		%>

        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        chart.draw(data, {width: 1500, height: 840});
      }
    </script>
</head>
<body>
<div id="chart_div"></div>

</body>
</html>